package com.evildog.workspace.life.application.task;

import com.evildog.workspace.life.application.consts.RedisKeyConst;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

@Component
@AllArgsConstructor
@Slf4j
public class RemindTask {

    private final RedissonClient redissonClient;

    /**
     * 每天早上8点，生成天气数据
     */
    @Scheduled(cron = "0 0 0 1 1 ? ")
    public void geneRemind() {
        RLock lock = redissonClient.getLock(RedisKeyConst.WEATHER_LOCK);
        try {
            if(lock.tryLock()){
                LocalDate now = LocalDate.now();


            }
        } catch (Exception e) {
            log.error("geneRemind Error occurred",e);
        } finally {
            lock.unlock();
        }
    }
}
